<?php
declare (strict_types = 1);

namespace app\command;

use app\common\model\Order as ModelOrder;
use app\common\model\PublicStatus;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class Order extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('order')
            ->setDescription('订单信息');
    }

    protected function execute(Input $input, Output $output)
    {
         ModelOrder::where(['status'=>PublicStatus::PAY_STATUS_ZERO])->chunk(100, function ($orders) use($output){
            foreach($orders  as $key => $order){
                $output->writeln('=========================循环第' . ($key + 1) . '个数据，开始循环订单的ID:' . $order['id'] . '=====================================');
                if(isOrderExpired($order['expire_at'])){
                   $output->writeln('==================================更改订单过期状态=====================================');
                   $order->save(['status'=>PublicStatus::PAY_STATUS_TWO]);
                }else{
                    $output->writeln('==================================未到过期时间=====================================');
                }
            }
        });
        // 指令输出
        $output->writeln('order');
    }
}
